<template>
	<vxe-radio-group v-model="queryParams[config.fieldName]">
		<vxe-radio v-for="(item, index) in dataSourceList" :key="index" :label="item[config.dictValue]" :content="item[config.dictLabel]"></vxe-radio>
	</vxe-radio-group>
</template>

<script>
import { requestApi } from "../../api";

export default {
  name: "vxeCodeRadio",
  props:{
	config: {
		type: Object,
		default: () => {}
	},
	queryParams: {
		type: Object,
		default: () => {}
	},
	json: {
		type: Object,
		default: () => {}
	},
  },
  data() {
    return {
		dataSourceList: []
    };
  },
  computed: {
  },
  mounted() {
		this.getDataSource(this.config.dataSource)
  },
  methods: {
		async getDataSource(dataSource) {
			const configDataSource = this.json.dataSource.find(item => item.name === dataSource);
			const [err, res] = await this.asyncHandle(requestApi(configDataSource));
			if (res) {
				this.dataSourceList = res.data
			}
			if (err) {
				console.log(`${this.config.dataSource}数据源请求错误`)
			}
		}
  },
};
</script>

<style lang="scss" scoped>
	.editComponent ::v-deep .el-input--medium .el-input__inner {
		height: 32px;
		line-height: 32px;
	}
	.editComponent.required {
		position: relative;
	}
	.editComponent.required::after {
		content: "*";
		position: absolute;
		top: 0;
		left: -9px;
		color: red;
		line-height: 1.2
	}
</style>
